package com.zhangjie.serviceorder.controller;

import com.zhangjie.internalcommon.dto.OrderInfo;
import com.zhangjie.serviceorder.mapper.OrderInfoMapper;
import com.zhangjie.serviceorder.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zj
 * @Date: 2024/1/19 - 01 - 19 - 17:45
 * @Description: com.zhangjie.serviceverificationcode.controller
 * @version: 1.0
 */
@RestController
public class TestController {

    @GetMapping("/test")
    public String test(){

        return "service-order";
    }

    @Autowired
    OrderInfoService orderInfoService;

    @Autowired
    OrderInfoMapper orderInfoMapper;

    @Value("${server.port}")
    String port;

    /**
     * 测试派单逻辑
     * @param orderId
     * @return
     */
    @GetMapping("/test-real-time-order/{orderId}")
    public String dispatchRealTimeOrder(@PathVariable("orderId") Long orderId) {
        System.out.println("service-order端口："+ port +" 并发测试：orderId：" + orderId);

        OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
        orderInfoService.dispatchRealTimeOrder(orderInfo);

        return "test-real-time-order     success";
    }
}
